<template>
  <el-dropdown trigger="click" @command="handleSetLanguage">
    <span style="user-select: none;cursor: pointer;">
      {{ languageDesc }}
      <i class="el-icon-arrow-down el-icon--right" />
    </span>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="zh-cn" :disabled="language === 'zh-cn'">
        中文简体
      </el-dropdown-item>
      <el-dropdown-item command="zh-tw" :disabled="language === 'zh-tw'">
        中文繁体
      </el-dropdown-item>
      <el-dropdown-item command="en" :disabled="language === 'en'">
        English
      </el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
export default {
  name: 'LangSet',
  props: {},
  data() {
    return {}
  },
  computed: {
    language() {
      return this.$store.getters['language/getLanguage']
    },
    languageDesc() {
      return this.$store.getters['language/getLanguageDesc']
    }
  },
  watch: {},
  created() {},
  mounted() {},
  methods: {
    handleSetLanguage(lang) {
      this.$i18n.locale = lang
      this.$store.dispatch('language/changeLanguage', lang)
    }
  }
}
</script>

<style scoped></style>
